﻿using SRB.Tg.DrawingStandard;
using SRB.Tg.Operate;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Teigha.DatabaseServices;
using Teigha.Geometry;

namespace SRB.Tg.Model
{
    public class PileCapRebar
    {

        List<Tuple<int,eSampleType, eDB, int, double,string>> rebarLst = new List<Tuple<int, eSampleType, eDB, int, double, string>>();
        Dictionary<int, int> dicNo = new Dictionary<int, int>();
        List<double> ArrAlongW, ArrAlongL;
        int N1 = 0, N2 = 0, N3 = 0, N4 = 0, N5 = 0, N6 = 0, N7 = 0, N8L = 0, N8W = 0, N9 = 0, N10 = 0;

        double radius = 0.3;
        eDB fsDB = eDB.DB6;
        string strfsDiameter = "C";
        PileCapRebarPara pileCap;
        string strDiameter = "%%130";
        string strMainDiameter = "D";
        string bridgeId = "";
        public PileCapRebar(PileCapRebarPara para, string _bridgeId = "")
        {

            bridgeId = _bridgeId;
            pileCap = para;
            InitPileNo();

            #region 配置钢筋           


            double NetWidthForN1 = pileCap.length - 2 * pileCap.concrete_protect_layer - GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter];
            double NetWidthForN2 = pileCap.width - 2 * pileCap.concrete_protect_layer - GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter];
            //double NetWidthForN3 = pileCap.height - 2 * pileCap.concrete_protect_layer - pileCap.bottom_reinforcement_layers_spacing * (pileCap.bottom_reinforcement_layers_number - 1) -pileCap.top_reinforcement_layers_spacing * (pileCap.top_reinforcement_layers_number - 1) - GeneralRebar.outerDia[N1Dia] / 2;

            ArrAlongW = RebarArrangement.ArrangeT2BRebar(NetWidthForN2, pileCap.top_l_reinforcement_spacing); //横桥向
            ArrAlongL = RebarArrangement.ArrangeT2BRebar(NetWidthForN1, pileCap.top_w_reinforcement_spacing);  //顺桥向
            //ArrAlongH = RebarArrangement.ArrangeSideRebar(NetWidthForN3, pileCap.around_reinforcement_spacing); // 侧面

            //ArrAlongHV = new List<double>(); //水平筋
            //ArrAlongWE = new List<double>(); // 横桥向架立筋
            //ArrAlongLE = new List<double>(); //顺桥向架立筋

            //#region 计算架立筋和水平筋算法 
            //double total = 0, totalhalf = 0, totalAll = 0;
            //bool isComputer = false;
            //if (Height / 10 > 300)
            //{
            //    totalAll = ArrAlongH.Sum();
            //    for (int i = 0; i < ArrAlongH.Count; i++)
            //    {
            //        total += ArrAlongH[i];
            //        totalhalf += ArrAlongH[i];
            //        if (totalhalf >= totalAll / 2)
            //        {
            //            if (i != ArrAlongH.Count - 1)
            //            {
            //                if (total >= vSp / 3 && total <= vSp * 2 / 3)
            //                {
            //                    ArrAlongHV.Add(total);
            //                    isComputer = true;
            //                }
            //            }
            //            totalhalf = 0;
            //        }
            //        int num = vSp / sideSapce;
            //        if (i % num == num - 1)
            //        {
            //            if (i != 0 && isComputer)
            //            {
            //                ArrAlongHV.Add(vSp - ArrAlongHV[ArrAlongHV.Count - 1]);
            //                isComputer = false;
            //            }
            //            else
            //                ArrAlongHV.Add(total);
            //            total = 0;
            //        }
            //    }
            //}

            //total = 0;
            //totalhalf = 0;
            //totalAll = ArrAlongW.Sum();
            //isComputer = false;
            //for (int i = 0; i < ArrAlongW.Count; i++)
            //{
            //    total += ArrAlongW[i];
            //    totalhalf += ArrAlongW[i];
            //    if (totalhalf >= totalAll / 2)
            //    {
            //        if (i != ArrAlongW.Count - 1)
            //        {
            //            if (total >= eSp / 3 && total <= eSp * 2 / 3)
            //            {
            //                ArrAlongWE.Add(total);
            //                isComputer = true;
            //            }
            //        }
            //        totalhalf = 0;
            //    }
            //    int num = eSp / t2bSapce;
            //    if (i % num == num - 1)
            //    {
            //        if (i != 0 && isComputer)
            //        {
            //            ArrAlongWE.Add(eSp - ArrAlongWE[ArrAlongWE.Count - 1]);
            //            isComputer = false;
            //        }
            //        else
            //            ArrAlongWE.Add(total);
            //        total = 0;
            //    }
            //}
            //total = 0;
            //totalhalf = 0;
            //isComputer = false;
            //totalAll = ArrAlongL.Sum();
            //for (int i = 0; i < ArrAlongL.Count; i++)
            //{
            //    total += ArrAlongL[i];
            //    totalhalf += ArrAlongL[i];
            //    if (totalhalf >= totalAll / 2)
            //    {
            //        if (i != ArrAlongL.Count - 1)
            //        {
            //            if (total >= eSp / 3 && total <= eSp * 2 / 3)
            //            {
            //                ArrAlongLE.Add(total);
            //                isComputer = true;
            //            }
            //        }
            //        totalhalf = 0;
            //    }
            //    int num = eSp / t2bSapce;
            //    if (i % num == num - 1)
            //    {
            //        if (i != 0 && isComputer)
            //        {
            //            ArrAlongLE.Add(eSp - ArrAlongLE[ArrAlongLE.Count - 1]);
            //            isComputer = false;
            //        }
            //        else
            //            ArrAlongLE.Add(total);
            //        total = 0;
            //    }
            //}
            //#endregion
            #endregion
            switch (para.reinforcement_grade)
            {
                case "HRB300":
                    strDiameter = "A";
                    break;
                case "HRB335":
                    strDiameter = "B";
                    break;
                case "HRB400":
                    strDiameter = "C";
                    break;
                case "HRB500":
                    strDiameter = "D";
                    break;
                case "HRB500E":
                    strDiameter = "D";
                    break;
                case "HRB600E":
                    strDiameter = "E";
                    break;
                case "HRB650E":
                    strDiameter = "F";
                    break;
                case "HRB700":
                    strDiameter = "G";
                    break;
                default:
                    strDiameter = "D";
                    break;
            }
            switch (para.main_reinforcement_grade)
            {
                case "HRB300":
                    strMainDiameter = "A";
                    break;
                case "HRB335":
                    strMainDiameter = "B";
                    break;
                case "HRB400":
                    strMainDiameter = "C";
                    break;
                case "HRB500":
                    strMainDiameter = "D";
                    break;
                case "HRB500E":
                    strMainDiameter = "D";
                    break;
                case "HRB600E":
                    strMainDiameter = "E";
                    break;
                case "HRB650E":
                    strMainDiameter = "F";
                    break;
                case "HRB700":
                    strMainDiameter = "G";
                    break;
                default:
                    strMainDiameter = "D";
                    break;
            }
        }
 
       

        public void PlotElevationA(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            if(scale<=10)
            radius = radius * scale;
            else
                radius = 0.15 * scale;
            double LA = 0;
            //List<Point2d> ptList = new List<Point2d>();
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -25 * scale);
            Point3d ptDim = M1.C3D(0, 20 * scale);
            Point3d ptDimL = M1.C3D(-0.5 * pileCap.length - 15 * scale);
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitle(db,insertPoint, ref ext, "A-A(横桥向)","", scale);


            ////绘制中心线
            //PLPloter.AddScaleLine(M1.C2D(0, 50 * scale), M1.C2D(0, -pileCap.height -15*scale), ref ext, "H中心线",scale);

            #region  绘制外轮廓
  
            //承台
            PLPloter.AddPloy4(db, M1, 0.5 * pileCap.length, 0.5 * pileCap.length, pileCap.height, ref ext, "H细线");
            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.length), M1.C3D(0.5 * pileCap.length), ptDim, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.length), M1.C3D(-0.5 * pileCap.length,-pileCap.height), ptDimL, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);


            #region 桩基外轮廓绘制
            double halfPile = 15 * scale;
            Point2d ptPileT = M1.C2D(0, -pileCap.height);
            double pileDia = pileCap.pile_diameter;
            string[] span = pileCap.span_l.Split('+');
            List<double> spanLst = new List<double>();
            double total = 0;
            for (int i = 0; i < span.Length; i++)
            {
                if (span[i].Contains("*"))
                {
                    string[] sp = span[i].Split('*');
                    int m = int.Parse(sp[0]);
                    double v = double.Parse(sp[1]);
                    for (int n = 0; n < m; n++)
                    {
                        spanLst.Add(v);
                        total += v;
                    }
                }
                else
                {
                    if (double.Parse(span[i]) > 0)
                    {
                        spanLst.Add(double.Parse(span[i]));
                        total += double.Parse(span[i]);
                    }
                    else
                    {
                        spanLst.Add(0);
                    }
                }
            }
            Point2d ptSt = ptPileT.C2D(-total * 0.5);

            if (spanLst.Count > 0)
            {
                Point2d ptP1 = ptSt.C2D(-pileDia * 0.5);
                Point2d ptP2 = ptSt.C2D(pileDia * 0.5);
                //桩基
                PLPloter.AddLine(db,ptP1.C2D(0,10), ptP1.C2D(0, -halfPile), ref ext, "H墩身");
                PLPloter.AddLine(db,ptP2.C2D(0, 10), ptP2.C2D(0, -halfPile), ref ext, "H墩身");
                PLPloter.AddScaleLine(db, ptP1.C2D(0, 10), ptP2.C2D(0, 10), ref ext, "H虚线",5);
                PLPloter.AddUpperArcBreakLine(db, ptSt.C2D(0, -halfPile), ref ext, pileDia, "H细线");
              
                for (int i = 0; i < spanLst.Count; i++)
                {
                    if (spanLst[i] > 0)
                    {
                        ptSt = ptSt.C2D(spanLst[i]);
                        ptP1 = ptSt.C2D(-pileDia * 0.5);
                        ptP2 = ptSt.C2D(pileDia * 0.5);
                      
                        //桩基
                        PLPloter.AddLine(db,ptP1.C2D(0, 10), ptP1.C2D(0, -halfPile), ref ext, "H墩身");
                        PLPloter.AddLine(db,ptP2.C2D(0, 10), ptP2.C2D(0, -halfPile), ref ext, "H墩身");
                        PLPloter.AddScaleLine(db, ptP1.C2D(0, 10), ptP2.C2D(0, 10), ref ext, "H虚线", 5);

                        PLPloter.AddUpperArcBreakLine(db, ptSt.C2D(0, -halfPile), ref ext, pileDia, "H细线");
                     
                    }
                }
            }

            #endregion


            #endregion

            #region 绘制钢筋

            double diaX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double diaY = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double LT = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1+ GeneralRebar.outerDiaNew[pileCap.around_l_reinforcement_diameter] * 0.1 * 0.5), 1);
            double LH = Math.Round(pileCap.height - pileCap.concrete_protect_layer-10-  GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1*0.5 - GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1 * 0.5 - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1, 1); ;
            double LN1 = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1), 1);
            double LH2 = Math.Round(pileCap.height - pileCap.concrete_protect_layer - 10 - GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1* 0.5 - GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1 * 0.5 - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1, 1);
            Point2d ptTop = M1.C2D(0, -pileCap.concrete_protect_layer- diaY);
            PLPloter.AddPloy4(db, ptTop.C2D(0, -radius), 0.5 * (LN1 + radius*2), 0.5 * (LN1 + radius * 2), LH, ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            List<Point3d> ptB34Lst = new List<Point3d>();
            List<double> topSpaceLst = new List<double>();
            string topString = "";
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer+ GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1  , 0), radius, LT, LT, pileCap.top_w_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_l_reinforcement_diameter] * 0.1 * 0.5, 0, out ptLst, out topSpaceLst, out topString, eDirection.E_TOP);
            if (pileCap.top_reinforcement_layers_number > 1)
            {
                for (int i = 1; i < pileCap.top_reinforcement_layers_number; i++)
                {
                    PLPloter.AddLine(db,ptTop.C2D(-0.5 * (LN1 + radius * 2), -pileCap.top_reinforcement_layers_spacing * i - radius), ptTop.C2D(0.5 * (LN1 + radius * 2),- pileCap.top_reinforcement_layers_spacing * i - radius), ref ext, "H钢筋");
                    //SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5, pileCap.bottom_reinforcement_layers_spacing * i), radius, pileCap.length, LT, pileCap.bottom_l_reinforcement_spacing, diaBX, diaBY, out ptB56Lst, eDirection.E_TOP);
                    //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0+ pileCap.bottom_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, radius, out ptB56Lst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);
                    //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, diaBY, out ptB56Lst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);
                    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, -pileCap.top_reinforcement_layers_spacing * i ), radius, LT, LT, pileCap.top_w_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_l_reinforcement_diameter] * 0.1 * 0.5, 0, out ptB34Lst, out topSpaceLst, out topString, eDirection.E_TOP);
                }
            }

            //2、底部钢筋
            Point2d ptBotom = ptTop.C2D(0, -LH);

            double diaBX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.bottom_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double diaBY = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.bottom_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);

            List<Point3d> ptBLst = new List<Point3d>();
            List<Point3d> ptB56Lst = new List<Point3d>();
            List<double> bottomSpaceLst = new List<double>();
            string bottomString = "";
            //SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5), radius, pileCap.length, LT, pileCap.bottom_l_reinforcement_spacing, diaBX, diaBY, out ptBLst, eDirection.E_TOP);
            //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, radius, out ptBLst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, diaBY, out ptBLst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);

            //ptList = new List<Point2d>();
            if (pileCap.bottom_reinforcement_layers_number >1)
            {
                for(int i=1;i< pileCap.bottom_reinforcement_layers_number;i++)
                {
                    PLPloter.AddLine(db,ptBotom.C2D(-0.5 * (LN1 + radius * 2), pileCap.bottom_reinforcement_layers_spacing * i-radius), ptBotom.C2D(0.5 * (LN1 + radius * 2), pileCap.bottom_reinforcement_layers_spacing * i - radius), ref ext, "H钢筋");
                    //SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5, pileCap.bottom_reinforcement_layers_spacing * i), radius, pileCap.length, LT, pileCap.bottom_l_reinforcement_spacing, diaBX, diaBY, out ptB56Lst, eDirection.E_TOP);
                    //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0+ pileCap.bottom_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, radius, out ptB56Lst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);
                    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, diaBY, out ptB56Lst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);

                }
            }

           

            //3、侧面钢筋，纵横方向
            //Point2d ptLeft = ptBotom.C2D(0, pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number);
            Point2d ptLeft = ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number);
            //左侧
            double diaAX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double diaAY = 0;
            double HL = LH - pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number- pileCap.top_reinforcement_layers_spacing * pileCap.top_reinforcement_layers_number;

            List<Point3d> ptB78Lst = new List<Point3d>();
            List<double> space78Lst = new List<double>();
            string str67 = "";
            SteelBarPileCap.CreateCircleHatchListNew(db, ref ext, ptLeft.C2D(diaX), radius, pileCap.height - 2 * pileCap.concrete_protect_layer - pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number, HL, pileCap.around_reinforcement_spacing, 0, 0, out ptB78Lst,out space78Lst,out str67, eDirection.E_RIGHT);

            Point2d ptRight = ptBotom.C2D(pileCap.length * 0.5 - pileCap.concrete_protect_layer - GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number);
            List <Point3d> ptB87Lst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptRight.C2D(-diaX), radius, pileCap.height - 2 * pileCap.concrete_protect_layer - pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number, HL, pileCap.around_reinforcement_spacing, 0, 0, out ptB87Lst, eDirection.E_LEFT);

            List<Point2d> ptList = new List<Point2d>();
            //侧面竖立方向
            List<double> eSpaceLst = new List<double>();
         
            double LTT = pileCap.length - 2 * (pileCap.concrete_protect_layer + (int)pileCap.around_h_reinforcement_diameter * 0.1 * 0.5) - pileCap.erection_reinforcement_l_spacing * 0.5;
            int numErection = (int)(LTT / pileCap.erection_reinforcement_l_spacing);
            int numL = (int)(pileCap.erection_reinforcement_l_spacing / pileCap.around_h_reinforcement_spacing);
            double startW = 0;
            for (int i = 0; i < numL; i++)
            {
                startW += topSpaceLst[i];
            }
            for (int i = 1; i <= numErection; i++)
            {
               
                PLPloter.AddLine(db,ptTop.C2D(-LN1 * 0.5 + diaX + startW + pileCap.erection_reinforcement_l_spacing *(i-1)- radius, -radius ), ptBotom.C2D(-LN1 * 0.5 + diaX + startW  + pileCap.erection_reinforcement_l_spacing *(i - 1)-radius, -radius), ref ext, "H钢筋");
                ptList.Add(ptTop.C2D(-LN1 * 0.5 + diaX + startW + pileCap.erection_reinforcement_l_spacing * (i - 1)- radius, -radius));
                if (i == 1)
                {
                    eSpaceLst.Add(startW + radius);
                }
                else
                {
                    eSpaceLst.Add(pileCap.erection_reinforcement_w_spacing);
                }
            }

            List<double> hSpaceLst = new List<double>();
            int numH = 0;
            if (pileCap.height>300)
            {
                numH = (int)(HL / pileCap.erection_reinforcement_h_spacing);
                for (int i = 1; i <= numH; i++)
                {
                    PLPloter.AddLine(db,ptB78Lst[0].C2D(0,HL*i/(numH+1)), ptB87Lst[0].C2D(0,HL * i / (numH + 1)), ref ext, "H钢筋");
                    hSpaceLst.Add(HL/ (numH + 1));
                }
            }
            #region  钢筋网
            //double NetWidthForN1 = pileCap.length - 2 * pileCap.concrete_protect_layer - GeneralRebar.outerDiaNew[pileCap.reinforcement_net_w_diameter]*0.1;
         
           
            //List<double> ArrAlongL = RebarArrangement.ArrangeT2BRebarNew(NetWidthForN1, pileCap.bottom_l_reinforcement_spacing);  //顺桥向
            //List<Point3d> netLst = new List<Point3d>();
            //if (pileCap.reinforcement_net_l_diameter != eDB.None)
            //{
            //    SteelBarPileCap.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * pileCap.length + pileCap.concrete_protect_layer, -pileCap.height + pileCap.concrete_protect_layer),
            //         radius, ArrAlongL, scale, GeneralRebar.outerDiaNew[pileCap.reinforcement_net_w_diameter] * 0.1, out netLst,true, "H点筋", false);
            //}
            #endregion
            #endregion

            #region  标注

            DimPloter.DimRot(db, ptTop.C3D(-pileCap.length * 0.5), ptLst[0], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, ptLst[0], ptLst[ptLst.Count - 1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, topString, Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, ptTop.C3D(pileCap.length * 0.5), ptLst[ptLst.Count - 1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);

            DimPloter.DimRadius(db,M1.C3D(pileCap.length * 0.35, 0), M1.C3D(pileCap.length * 0.35, 0.01), 2 * scale, ref ext, scale, "净" + pileCap.concrete_protect_layer);
            DimPloter.DimRadius(db,M1.C3D(pileCap.length * 0.5 - 0.01, -pileCap.height*0.5), M1.C3D(pileCap.length * 0.5, -pileCap.height * 0.5), 2 * scale, ref ext, scale, "净" + pileCap.concrete_protect_layer);

            string btH = (10 + GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaNew[pileCap.bottom_w_reinforcement_diameter] * 0.1 * 0.5).ToString("0.0");
            double va1 = double.Parse(btH);
            int va2 = (int)va1;
            if (va1 == va2)
                btH = va2.ToString();

            DimPloter.DimRot(db, M1.C3D(-pileCap.length * 0.5 + 5 * scale, -pileCap.height), ptBLst[0], ptDimL.C3D(5 * scale), ref ext, 90, scale, btH, Unit.Centimeter, Unit.Centimeter, 0);
            //DimPloter.DimRot(db, M1.C3D(-pileCap.length * 0.5+5*scale, -pileCap.height), ptBLst[0], ptDimL.C3D(5 * scale), ref ext, 90, scale, btH, Unit.Centimeter, Unit.Centimeter, 1);
            //DimPloter.DimRot(db,  ptBLst[0], ptBLst[0].C3D(0, pileCap.bottom_reinforcement_layers_spacing), ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 0);
            DimPloter.DimRot(db, ptBLst[0].C3D(), ptB78Lst[ptB78Lst.Count-1].C3D(), ptDimL.C3D(5 * scale), ref ext, 90, scale, str67, Unit.Centimeter, Unit.Centimeter, 1);
            va1 = M1.C3D(-pileCap.length * 0.5, 0).Y - ptB78Lst[ptB78Lst.Count - 1].C3D().Y;
            va2 = (int)va1;
            if (va1 > va2)
                DimPloter.DimRot(db, M1.C3D(-pileCap.length * 0.5, 0), ptB78Lst[ptB78Lst.Count - 1].C3D(), ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
            else
                DimPloter.DimRot(db, M1.C3D(-pileCap.length * 0.5, 0), ptB78Lst[ptB78Lst.Count - 1].C3D(), ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 0);
            #endregion

            #region 钢筋编号

            List<double> lList = new List<double>();
            for (int i = 0; i < pileCap.bottom_reinforcement_layers_number; i++)
            {
                if (i < pileCap.bottom_reinforcement_layers_number - 1)
                    lList.Add(pileCap.bottom_reinforcement_layers_spacing);
                else
                    lList.Add(0);
            }

            int num = (int)(LT / pileCap.top_w_reinforcement_spacing);
            double avg = Math.Round((LT - pileCap.top_w_reinforcement_spacing * (num - 1)) * 0.5, 1);
            double dLen = avg + pileCap.top_w_reinforcement_spacing * ((int)(num - num * 0.3)) + pileCap.top_w_reinforcement_spacing * 0.5;
            //1,3
            RebarPLPloter.CreateLineArrowDB(db, ref ext, ptBotom.C3D(-LT * 0.5 + dLen, pileCap.bottom_reinforcement_layers_spacing * (pileCap.bottom_reinforcement_layers_number - 1) - radius), ArrowDirection.South, lList, new List<double>(), dicNo[1].ToString(), scale, true, 5);
            lList = new List<double>();
            for (int i = 0; i < pileCap.top_reinforcement_layers_number; i++)
            {
                if (i < pileCap.top_reinforcement_layers_number - 1)
                    lList.Add(pileCap.top_reinforcement_layers_spacing);
                else
                    lList.Add(0);
            }
            RebarPLPloter.CreateLineArrowDB(db, ref ext, ptTop.C3D(-LT*0.5+ dLen, -radius), ArrowDirection.South, lList, new List<double>(), dicNo[3].ToString(), scale, true, 2);
         
            //5
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(LN1 * 0.5+radius, -pileCap.height * 2 / 3), ArrowDirection.East, new List<double>(), new List<double>(), dicNo[5].ToString(), scale, true, 5);
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-LN1 * 0.5- radius, -pileCap.height * 2 / 3), ArrowDirection.West, new List<double>(), new List<double>(), dicNo[5].ToString(), scale, true, 5);
            //8
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-LN1 * 0.5- radius, -pileCap.height / 4), ArrowDirection.East, new List<double>(), eSpaceLst, dicNo[8].ToString(), scale, false, 1);
            if(numH>0)
               RebarPLPloter.CreateLineArrowDB(db, ref ext, ptB78Lst[0].C3D(pileCap.length*0.2, HL* numH / (numH + 1)), ArrowDirection.North, hSpaceLst, new List<double>(), dicNo[9].ToString(), scale, true, 1);
            //2,4

            //SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_BOTTOM, ptLst, dicNo[4].ToString(), 4, 3, scale, false, 4 * scale);
            SteelBarPileCap.CreateBottomRebarPointLine(db, ref ext, ptLst, pileCap.top_reinforcement_layers_number, pileCap.top_reinforcement_layers_spacing, dicNo[4].ToString(), 4, 3, scale, 3 * scale);
            SteelBarPileCap.CreateBottomRebarPointLine(db, ref ext, ptB56Lst, pileCap.bottom_reinforcement_layers_number, pileCap.bottom_reinforcement_layers_spacing, dicNo[2].ToString(), 4, 3, scale, 3 * scale);
            N4 = ptLst.Count;
            N2 = ptBLst.Count;
            ////钢筋网       
            //SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_TOP, netLst, dicNo[9].ToString(), 4, 3, scale, false, 5 * scale);
            N8L = ptList.Count;
            //N9 = netLst.Count;
            SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_RIGHT, ptB78Lst, dicNo[6].ToString(), 2, 0, scale, false, 3 * scale);

            SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_LEFT, ptB87Lst, dicNo[6].ToString(), 2, 0, scale, false, 3 * scale);
            N6 = ptB87Lst.Count*2;
            #endregion

        }
        public void PlotElevationB(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            //radius = radius * scale;
            double LA = 0;
            ext = new Extents2d(insertPoint, insertPoint);
            //List<Point2d> ptList = new List<Point2d>();
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -25 * scale);
            Point3d ptDim = M1.C3D(0, 20 * scale);
            Point3d ptDimL = M1.C3D(-0.5 * pileCap.width - 12 * scale);
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitle(db,insertPoint, ref ext, "B-B(顺桥向)", "", scale);

            ////绘制中心线
            //PLPloter.AddScaleLine(M1.C2D(0, 50 * scale), M1.C2D(0, -pileCap.height - 15 * scale), ref ext, "H中心线", scale);

            #region  绘制外轮廓

            //承台
            PLPloter.AddPloy4(db, M1, 0.5 * pileCap.width, 0.5 * pileCap.width, pileCap.height, ref ext, "HM细线");
            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.width), M1.C3D(0.5 * pileCap.width), ptDim, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.width), M1.C3D(-0.5 * pileCap.width, -pileCap.height), ptDimL, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);

            #region 桩基外轮廓绘制
            double halfPile = 15 * scale;
            Point2d ptPileT = M1.C2D(0, -pileCap.height);
            double pileDia = pileCap.pile_diameter;
            string[] span = pileCap.span_w.Split('+');
            List<double> spanLst = new List<double>();
            double total = 0;
            for (int i = 0; i < span.Length; i++)
            {
                if (span[i].Contains("*"))
                {
                    string[] sp = span[i].Split('*');
                    int m = int.Parse(sp[0]);
                    double v = double.Parse(sp[1]);
                    for (int n = 0; n < m; n++)
                    {
                        spanLst.Add(v);
                        total += v;
                    }
                }
                else
                {
                    if (double.Parse(span[i]) > 0)
                    {
                        spanLst.Add(double.Parse(span[i]));
                        total += double.Parse(span[i]);
                    }
                    else
                    {
                        spanLst.Add(0);
                    }
                }
            }
            Point2d ptSt = ptPileT.C2D(-total * 0.5);

            if (spanLst.Count > 0)
            {
                Point2d ptP1 = ptSt.C2D(-pileDia * 0.5);
                Point2d ptP2 = ptSt.C2D(pileDia * 0.5);
                //桩基
                PLPloter.AddLine(db,ptP1.C2D(0, 10), ptP1.C2D(0, -halfPile), ref ext, "H墩身");
                PLPloter.AddLine(db,ptP2.C2D(0, 10), ptP2.C2D(0, -halfPile), ref ext, "H墩身");
                PLPloter.AddScaleLine(db, ptP1.C2D(0, 10), ptP2.C2D(0, 10), ref ext, "H虚线", 5);
                PLPloter.AddUpperArcBreakLine(db, ptSt.C2D(0, -halfPile), ref ext, pileDia, "H细线");

                for (int i = 0; i < spanLst.Count; i++)
                {
                    if (spanLst[i] > 0)
                    {
                        ptSt = ptSt.C2D(spanLst[i]);
                        ptP1 = ptSt.C2D(-pileDia * 0.5);
                        ptP2 = ptSt.C2D(pileDia * 0.5);

                        //桩基
                        PLPloter.AddLine(db,ptP1.C2D(0, 10), ptP1.C2D(0, -halfPile), ref ext, "H墩身");
                        PLPloter.AddLine(db,ptP2.C2D(0, 10), ptP2.C2D(0, -halfPile), ref ext, "H墩身");
                        PLPloter.AddScaleLine(db, ptP1.C2D(0, 10), ptP2.C2D(0, 10), ref ext, "H虚线", 5);

                        PLPloter.AddUpperArcBreakLine(db, ptSt.C2D(0, -halfPile), ref ext, pileDia, "H细线");

                    }
                }
            }

            #endregion


            #endregion
            #region 绘制钢筋

            double diaX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double diaY = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double LT = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1*0.5), 1);
            double LH = Math.Round(pileCap.height - pileCap.concrete_protect_layer - 10 - GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1 - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1 * 0.5 - GeneralRebar.outerDiaNew[pileCap.bottom_w_reinforcement_diameter] * 0.1 * 0.5, 1); ;
            double LN1 = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1), 1);
            double LH2 = Math.Round(pileCap.height - pileCap.concrete_protect_layer - 10 - GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1 - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1*0.5 - GeneralRebar.outerDiaNew[pileCap.bottom_w_reinforcement_diameter] * 0.1*0.5, 1);
            Point2d ptTop = M1.C2D(0, -pileCap.concrete_protect_layer-GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1- diaY);
            PLPloter.AddPloy4(db, ptTop.C2D(0, radius), 0.5 * (LN1+ radius*2), 0.5 * (LN1 + radius*2), LH, ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            List<Point3d> ptB34Lst = new List<Point3d>();
            List<double> topSpaceLst = new List<double>();
            string topString = "";
            //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.width * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LT, LT, pileCap.top_l_reinforcement_spacing, diaX, 0, out ptLst, out topSpaceLst, out topString, eDirection.E_BOTTOM);
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.width * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LT, LT, pileCap.top_l_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5, 0, out ptLst, out topSpaceLst, out topString, eDirection.E_TOP);
            if (pileCap.top_reinforcement_layers_number > 1)
            {
                for (int i = 1; i < pileCap.top_reinforcement_layers_number; i++)
                {
                    PLPloter.AddLine(db,ptTop.C2D(-0.5 * (LN1 + radius * 2), -pileCap.top_reinforcement_layers_spacing * i + radius), ptTop.C2D(0.5 * (LN1 + radius * 2), -pileCap.top_reinforcement_layers_spacing * i + radius), ref ext, "H钢筋");
                    //SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5, pileCap.bottom_reinforcement_layers_spacing * i), radius, pileCap.length, LT, pileCap.bottom_l_reinforcement_spacing, diaBX, diaBY, out ptB56Lst, eDirection.E_TOP);
                    //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0+ pileCap.bottom_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, radius, out ptB56Lst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);
                    //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, diaBY, out ptB56Lst, out bottomSpaceLst, out bottomString, eDirection.E_TOP);
                    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.width * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, -pileCap.top_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_l_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5, 0, out ptB34Lst, out topSpaceLst, out topString, eDirection.E_TOP);
                }
            }

            //2、底部钢筋
            Point2d ptBotom = ptTop.C2D(0, -LH);

            double diaBX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double diaBY = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);

            List<Point3d> ptBLst = new List<Point3d>();
            List<Point3d> ptB56Lst = new List<Point3d>();
            List<double> bottomSpaceLst = new List<double>();
            string bottomString = "";
            //SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5), radius, pileCap.length, LT, pileCap.bottom_l_reinforcement_spacing, diaBX, diaBY, out ptBLst, eDirection.E_TOP);
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.width * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, 0, out ptBLst, out bottomSpaceLst, out bottomString, eDirection.E_BOTTOM);

            //ptList = new List<Point2d>();
            if (pileCap.bottom_reinforcement_layers_number > 1)
            {
                for (int i = 1; i < pileCap.bottom_reinforcement_layers_number; i++)
                {
                    PLPloter.AddLine(db,ptBotom.C2D(-LN1 * 0.5- radius, pileCap.bottom_reinforcement_layers_spacing * i + radius), ptBotom.C2D(LN1 * 0.5+ radius, pileCap.bottom_reinforcement_layers_spacing * i + radius), ref ext, "H钢筋");
                    //SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptBotom.C2D(-LT * 0.5, pileCap.bottom_reinforcement_layers_spacing * i), radius, pileCap.length, LT, pileCap.bottom_l_reinforcement_spacing, diaBX, diaBY, out ptB56Lst, eDirection.E_TOP);
                    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.width * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * i), radius, LT, LT, pileCap.top_w_reinforcement_spacing, diaX, 0, out ptB56Lst, out bottomSpaceLst, out bottomString, eDirection.E_BOTTOM);

                }
            }


            //3、侧面钢筋，纵横方向
            //Point2d ptLeft = ptBotom.C2D(0, pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number);
            Point2d ptLeft = ptBotom.C2D(-pileCap.width * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number);
            //左侧
            double diaAX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double diaAY = 0;
            double HL = LH - pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number - pileCap.top_reinforcement_layers_spacing * pileCap.top_reinforcement_layers_number;

            List<Point3d> ptB78Lst = new List<Point3d>();
            List<double> space78Lst = new List<double>();
            string str67 = "";
            SteelBarPileCap.CreateCircleHatchListNew(db, ref ext, ptLeft.C2D(diaX), radius, pileCap.height - 2 * pileCap.concrete_protect_layer - pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number, HL, pileCap.around_reinforcement_spacing, 0, diaAY, out ptB78Lst, out space78Lst,out str67,eDirection.E_RIGHT);

            //Point2d ptRight = ptLeft.C2D(LN1 * 0.5 - radius);
            Point2d ptRight = ptBotom.C2D(pileCap.width * 0.5 - pileCap.concrete_protect_layer - GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number);
            List<Point3d> ptB87Lst = new List<Point3d>();
            SteelBarPileCap.CreateCircleHatchList(db, ref ext, ptRight.C2D(-diaX), radius, pileCap.height - 2 * pileCap.concrete_protect_layer - pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number, HL, pileCap.around_reinforcement_spacing, 0, diaAY, out ptB87Lst, eDirection.E_LEFT);

            List<Point2d> ptList = new List<Point2d>();
            //侧面竖立方向
            List<double> eSpaceLst = new List<double>();
            int numErection =(int) Math.Round((LT / pileCap.erection_reinforcement_w_spacing),0);
            int numErection1 = (int)(LT / pileCap.erection_reinforcement_w_spacing);
            int numL = (int)(pileCap.erection_reinforcement_w_spacing / pileCap.around_h_reinforcement_spacing);
            double startW = 0;
            for (int i = 0; i < numL; i++)
            {
                startW += topSpaceLst[i];
            }
       
            for (int i = 1; i < numErection; i++)
            {

                PLPloter.AddLine(db,ptTop.C2D(-LN1 * 0.5 + startW + diaX + pileCap.erection_reinforcement_w_spacing * (i - 1) - radius, radius), ptBotom.C2D(-LN1 * 0.5 + startW + diaX + pileCap.erection_reinforcement_w_spacing * (i - 1) - radius, radius), ref ext, "H钢筋");
                ptList.Add(ptTop.C2D(-LN1 * 0.5 + startW + diaX + pileCap.erection_reinforcement_w_spacing * (i - 1) - radius, radius));
                if(i==1)
                {
                    eSpaceLst.Add(startW+radius);
                }
                else
                {
                    eSpaceLst.Add( pileCap.erection_reinforcement_w_spacing);
                }
            }


            List<double> hSpaceLst = new List<double>();
            int numH = 0;
            if (pileCap.height > 300)
            {
                numH = (int)(HL / pileCap.erection_reinforcement_h_spacing);
                for (int i = 1; i <= numH; i++)
                {
                    PLPloter.AddLine(db,ptB78Lst[0].C2D(0, HL * i / (numH + 1)), ptB87Lst[0].C2D(0, HL * i / (numH + 1)), ref ext, "H钢筋");
                    hSpaceLst.Add(HL/ (numH + 1));
                }
            }
            #region  钢筋网
            //double NetWidthForN1 = pileCap.width - 2 * pileCap.concrete_protect_layer - GeneralRebar.outerDiaNew[pileCap.reinforcement_net_w_diameter] * 0.1;


            //List<double> ArrAlongL = RebarArrangement.ArrangeT2BRebarNew(NetWidthForN1, pileCap.bottom_l_reinforcement_spacing);  //顺桥向
            //List<Point3d> netLst=new List<Point3d>() ;
            //if (pileCap.reinforcement_net_l_diameter != eDB.None)
            //{
            //    SteelBarPileCap.CreateSingleLineHatch(db, ref ext, M1.C2D(-0.5 * pileCap.width + pileCap.concrete_protect_layer, -pileCap.height + pileCap.concrete_protect_layer),
            //         radius, ArrAlongL, scale, GeneralRebar.outerDiaNew[pileCap.reinforcement_net_w_diameter] * 0.1,out netLst,false,"H点筋",false);
            //}
            #endregion
            #endregion

            #region  标准
            DimPloter.DimRot(db, ptTop.C3D(-pileCap.width * 0.5), ptLst[0], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, ptLst[0], ptLst[ptLst.Count - 1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, topString, Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, ptTop.C3D(pileCap.width * 0.5), ptLst[ptLst.Count - 1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);

            //DimPloter.DimRadius(db,M1.C3D(pileCap.width * 0.35, 0), M1.C3D(pileCap.width * 0.35,0.01), 2 * scale, ref ext, scale, "净" + pileCap.concrete_protect_layer);

            //string btH = (10 + GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1 * 0.5).ToString("0.0");
            //DimPloter.DimRot(db, M1.C3D(-pileCap.width * 0.5, -pileCap.height), ptBLst[0], ptDimL.C3D(5 * scale), ref ext, 90, scale, btH, Unit.Centimeter, Unit.Centimeter, 1);
            //for (int i = 0; i < pileCap.bottom_reinforcement_layers_number; i++)
            //{
            //    if(i==0)
            //       DimPloter.DimRot(db, ptBLst[0], ptBLst[0].C3D(0,pileCap.bottom_reinforcement_layers_spacing), ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 0);
            //    else
            //        DimPloter.DimRot(db, ptBLst[0].C3D(0, pileCap.bottom_reinforcement_layers_spacing*i), ptBLst[0].C3D(0, pileCap.bottom_reinforcement_layers_spacing*(i-1)), ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 0);
            //}
            //DimPloter.DimRot(db, netLst[0], ptBLst[0], ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
            //DimPloter.DimRot(db, M1.C3D(-pileCap.length * 0.5, 0), ptLst[0].C3D(), ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
            #endregion

            #region 钢筋编号.
            int num = (int)(LT / pileCap.top_l_reinforcement_spacing);
            double avg = Math.Round((LT - pileCap.top_l_reinforcement_spacing * (num - 1)) * 0.5, 1);
            double dLen = avg + pileCap.top_l_reinforcement_spacing * ((int)(num - num * 0.3)) + pileCap.top_l_reinforcement_spacing * 0.5;

            List<double> lList = new List<double>();
            for (int i = 0; i < pileCap.bottom_reinforcement_layers_number; i++)
            {
                if (i < pileCap.bottom_reinforcement_layers_number - 1)
                    lList.Add(pileCap.bottom_reinforcement_layers_spacing);
                else
                    lList.Add(0);
            }
           
            //2,4
            RebarPLPloter.CreateLineArrowDB(db, ref ext, ptBotom.C3D(-LT*0.5+ dLen, pileCap.bottom_reinforcement_layers_spacing * (pileCap.bottom_reinforcement_layers_number - 1)+2* radius), ArrowDirection.South, lList, new List<double>(), dicNo[2].ToString(), scale, true, 4);
            lList = new List<double>();
            for (int i = 0; i < pileCap.top_reinforcement_layers_number; i++)
            {
                if (i < pileCap.top_reinforcement_layers_number - 1)
                    lList.Add(pileCap.top_reinforcement_layers_spacing);
                else
                    lList.Add(0);
            }
            RebarPLPloter.CreateLineArrowDB(db, ref ext, ptTop.C3D(-LT * 0.5 + dLen, radius), ArrowDirection.South, lList, new List<double>(), dicNo[4].ToString(), scale, true, 1);
            //5
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(LN1 * 0.5+radius, -pileCap.height*2/3), ArrowDirection.East, new List<double>(), new List<double>(), dicNo[5].ToString(), scale,true,5);
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-LN1 * 0.5- radius, -pileCap.height * 2 / 3), ArrowDirection.West, new List<double>(), new List<double>(), dicNo[5].ToString(), scale, true, 5);
            //4
            RebarPLPloter.CreateLineArrowDB(db, ref ext, M1.C3D(-LN1 * 0.5,-pileCap.height / 4), ArrowDirection.East, new List<double>(), eSpaceLst, dicNo[8].ToString(), scale, false,3.5);
            if (numH > 0)
                RebarPLPloter.CreateLineArrowDB(db, ref ext, ptB78Lst[0].C3D(pileCap.length * 0.2, HL * numH / (numH + 1)), ArrowDirection.North, hSpaceLst, new List<double>(), dicNo[10].ToString(), scale, true, 1);

            //2
            SteelBarPileCap.CreateBottomRebarPointLine(db, ref ext, ptLst, pileCap.top_reinforcement_layers_number, pileCap.top_reinforcement_layers_spacing, dicNo[3].ToString(), 4, 3, scale, 3 * scale);
            //SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_BOTTOM, ptLst, dicNo[3].ToString(), 4, 3, scale,false,5*scale);
            N3 = ptLst.Count;
            N1 = ptBLst.Count;
            SteelBarPileCap.CreateBottomRebarPointLine(db, ref ext, ptB56Lst, pileCap.bottom_reinforcement_layers_number, pileCap.bottom_reinforcement_layers_spacing, dicNo[1].ToString(), 4, 3, scale,4*scale);

            //钢筋网       
            //SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_TOP, netLst, dicNo[10].ToString(), 4, 3, scale, false, 5 * scale);
            N8W = ptList.Count;
            //N10 = netLst.Count;

            SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_LEFT, ptB78Lst, dicNo[7].ToString(), 2, 0, scale, false, 5 * scale);

            SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_RIGHT, ptB87Lst, dicNo[7].ToString(), 2, 0, scale, false, 5 * scale);
            N7 = ptB87Lst.Count*2;
            #endregion

        }

        public void PlotElevationPlan(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            //radius = radius * scale;
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -18* scale);

            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitle(db,insertPoint, ref ext, "平面", "", scale);
            Point3d ptDim = M1.C3D(0, 10 * scale);
            Point3d ptDimL = M1.C3D(-0.5 * pileCap.length - 10 * scale);
            #region  绘制外轮廓
            PLPloter.AddPloy4(db, M1, 0.5 * pileCap.length, 0.5 * pileCap.length, pileCap.width, ref ext, "HM细线");

            //for (int i = 0; i < pileLocation.Length; i++)
            //{
            //    double pSizeLen = double.Parse(pileSize[i].ToString());
            //    double pLen = double.Parse(pileLocation[i].ToString());

            //    PLPloter.AddCircle(M1.C2D(-0.5 * length + pLen, -width * 0.5), pSizeLen * 0.5, ref ext, "H虚线", scale);
            //}
            #region 桩基外轮廓绘制

            double pileDia = pileCap.pile_diameter;
            string[] span = pileCap.span_l.Split('+');
            List<double> spanLst = new List<double>();
            double total = 0;
            for (int i = 0; i < span.Length; i++)
            {
                if (span[i].Contains("*"))
                {
                    string[] sp = span[i].Split('*');
                    int m = int.Parse(sp[0]);
                    double v = double.Parse(sp[1]);
                    for (int n = 0; n < m; n++)
                    {
                        spanLst.Add(v);
                        total += v;
                    }
                }
                else
                {
                    if (double.Parse(span[i]) > 0)
                    {
                        spanLst.Add(double.Parse(span[i]));
                        total += double.Parse(span[i]);
                    }
                    else
                    {
                        spanLst.Add(0);
                    }
                }
            }
            string[] spanW = pileCap.span_w.Split('+');
            List<double> spanWLst = new List<double>();
            double totalW = 0;
            for (int i = 0; i < spanW.Length; i++)
            {
                if (spanW[i].Contains("*"))
                {
                    string[] sp = spanW[i].Split('*');
                    int m = int.Parse(sp[0]);
                    double v = double.Parse(sp[1]);
                    for (int n = 0; n < m; n++)
                    {
                        spanWLst.Add(v);
                        totalW += v;
                    }
                }
                else
                {
                    if (double.Parse(spanW[i]) > 0)
                    {
                        spanWLst.Add(double.Parse(spanW[i]));
                        totalW += double.Parse(spanW[i]);
                    }
                    else
                    {
                        spanWLst.Add(0);
                    }
                }
            }
            if (spanLst.Count > 0)
            {
                Point2d ptCir;
                double len = 0;
                double wlen = 0;
                for (int i = 0; i < spanLst.Count; i++)
                {
                    len += spanLst[i];
                  
                    if (i == 0)
                    {
                        for (int j = 0; j < spanWLst.Count; j++)
                        {
                            wlen += spanWLst[j];
                            if (j == 0)
                            {
                                ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5, -totalW * 0.5);
                                PLPloter.AddCircle(db,ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
                            }
                            if (spanWLst[j] > 0)
                            {
                                ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5, -totalW * 0.5 + wlen);
                                PLPloter.AddCircle(db, ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
                            }
                        }
                    }
                    if (spanLst[i] > 0)
                    {
                        wlen = 0;
                        for (int j = 0; j < spanWLst.Count; j++)
                        {
                            wlen += spanWLst[j];
                            if (j == 0)
                            {
                                ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5 + len, -totalW * 0.5);
                                PLPloter.AddCircle(db, ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
                            }
                            if (spanWLst[j] > 0)
                            {
                                ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5 + len, -totalW * 0.5 + wlen);
                                PLPloter.AddCircle(db, ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
                            }
                        }

                    }
                    
                }

            }

            #endregion


            //轮廓标注
            DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.length), M1.C3D(0.5 * pileCap.length), ptDim, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.length), M1.C3D(-0.5 * pileCap.length, -pileCap.width), ptDimL, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
            #endregion

            #region  绘制钢筋


            
            double diaX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5), 2, MidpointRounding.AwayFromZero);
            double diaY = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5), 2, MidpointRounding.AwayFromZero);

            double LT = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaNew[pileCap.around_l_reinforcement_diameter] * 0.1 * 0.5), 1);
            //double LT = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5),2);
            //double LH = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5),2);
            double LH = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5), 1);
            double N1 = LT - GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1;
            double N2 = LH - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1;
            Point2d ptTop = M1.C2D(0, -pileCap.concrete_protect_layer- diaY);
            //PLPloter.AddPloy4(ptTop.C2D(0,-radius ), 0.5 * (LT- radius * 2), 0.5 * (LT - radius * 2), LH- radius , ref ext, "H钢筋");
            List<Point3d> ptLst = new List<Point3d>();
            List<double> topSpaceLst = new List<double>();
            string topString = "";
            //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.length * 0.5+ pileCap.concrete_protect_layer,0), radius, LT, LT, pileCap.around_reinforcement_spacing, diaX, 0, out ptLst, out topSpaceLst, out topString, eDirection.E_TOP);
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LT, LT, pileCap.top_w_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_l_reinforcement_diameter] * 0.1 * 0.5, 0, out ptLst, out topSpaceLst, out topString, eDirection.E_TOP,true,"H点筋",false);

            Point2d ptBotom = M1.C2D(0, -pileCap.width+pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5);
            List<Point3d> ptBLst = new List<Point3d>();
            List<double> btSpaceLst = new List<double>();
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, -GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5), radius, LT, LT, pileCap.top_w_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_l_reinforcement_diameter] * 0.1 * 0.5, 0, out ptBLst,out btSpaceLst, out topString, eDirection.E_BOTTOM, true, "H点筋", false);

            List<Point3d> ptLLst = new List<Point3d>();
            string leftString = "";
            List<double> leftSpaceLst = new List<double>();
            //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer+ diaX, -diaY), radius, LH, LH, pileCap.around_reinforcement_spacing, 0, 0, out ptLLst, out leftSpaceLst, out leftString, eDirection.E_LEFT);
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LH, LH, pileCap.top_l_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5, 0, out ptLLst, out leftSpaceLst, out leftString, eDirection.E_LEFT, true, "H点筋", false);
            //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.width * 0.5 + pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LT, LT, pileCap.top_l_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5, 0, out ptLst, out topSpaceLst, out topString, eDirection.E_TOP);

            List<Point3d> ptRLst = new List<Point3d>();
            List<double> rightSpaceLst = new List<double>();
            //SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(pileCap.length * 0.5 - pileCap.concrete_protect_layer- diaX, -diaY), radius, LH, LH, pileCap.around_reinforcement_spacing, 0, 0, out ptRLst, out rightSpaceLst, out leftString, eDirection.E_RIGHT);
            SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(pileCap.length * 0.5 - pileCap.concrete_protect_layer - GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1, 0), radius, LH, LH, pileCap.top_l_reinforcement_spacing, GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1 * 0.5, 0, out ptRLst, out rightSpaceLst, out leftString, eDirection.E_RIGHT, true, "H点筋", false);

            List<double> tSpaceLst = new List<double>();
            List<double> rSpaceLst = new List<double>();
            for (int i=0;i< ptLst.Count;i++)
            {
                PLPloter.AddLine(db,ptLst[i].C2D(0), ptBLst[i].C2D(), ref ext, "H钢筋");
                if (i > 0)
                {
                    //if (i == 1)
                    //    tSpaceLst.Add(ptLst[i].C2D().X - ptLst[i - 1].C2D(0).X);
                    //else if (i == ptLst.Count - 2)
                    //{
                    //    tSpaceLst.Add(ptLst[i].C2D().X - ptLst[i - 1].C2D().X);
                    //    tSpaceLst.Add(ptLst[i + 1].C2D(0, -0).X - ptLst[i].C2D().X);
                    //}
                    //else
                        tSpaceLst.Add(ptLst[i].C2D().X - ptLst[i - 1].C2D().X);
                }
            }
            for (int i = 0; i < ptLLst.Count; i++)
            {
                PLPloter.AddLine(db,ptLLst[i].C2D(), ptRLst[i].C2D(), ref ext, "H钢筋");
                if (i > 0)
                {
                    //if (i == 1)
                    //    rSpaceLst.Add(ptLLst[i].C2D().Y - ptLLst[i - 1].C2D(0, 0).Y);
                    //else if (i == ptLLst.Count - 2)
                    //{
                    //    rSpaceLst.Add(ptLLst[i].C2D().Y - ptLLst[i - 1].C2D().Y);
                    //    rSpaceLst.Add(ptLLst[i + 1].C2D(0, -0).Y - ptLLst[i].C2D().Y);
                    //}
                    //else
                        rSpaceLst.Add(ptLLst[i].C2D().Y - ptLLst[i - 1].C2D().Y);
                }

            }

            double LTT = pileCap.length - 2 * (pileCap.concrete_protect_layer + (int)pileCap.around_h_reinforcement_diameter * 0.1 * 0.5) - pileCap.erection_reinforcement_l_spacing*0.5;
            int numErection = (int)((LH- pileCap.erection_reinforcement_w_spacing) / pileCap.erection_reinforcement_w_spacing)+1;
            for (int i = 1; i <= numErection; i++)
            {
                string eString = "";
                List<Point3d> ptALst = new List<Point3d>();
                int numW = (int)(pileCap.erection_reinforcement_w_spacing / pileCap.around_h_reinforcement_spacing);
                int numL = (int)(pileCap.erection_reinforcement_l_spacing / pileCap.around_h_reinforcement_spacing);
                SteelBarPileCap.CreateCircleHatchList(db, ref ext,new Point2d( ptLst[numL].X, ptLLst[numW].Y).C2D(radius, pileCap.erection_reinforcement_w_spacing * (i-1)-radius), radius, LTT, LTT, pileCap.erection_reinforcement_l_spacing, 0, 0, out ptALst, eDirection.E_TOP);
            }


            #endregion

            #region  标注 及编号

            int num = (int)(LT / pileCap.around_reinforcement_spacing);
            double avg = Math.Round((LT - pileCap.around_reinforcement_spacing * (num - 1)) * 0.5, 1);
            double dLen = avg + pileCap.around_reinforcement_spacing * ((int)(num - num * 0.75)) + pileCap.around_reinforcement_spacing * 0.5;

            int num1 = (int)(LH / pileCap.around_reinforcement_spacing);
            double avg1 = Math.Round((LH - pileCap.around_reinforcement_spacing * (num1 - 1)) * 0.5, 1);
            double dLen1 = avg + pileCap.around_reinforcement_spacing * ((int)(num - num * 0.25)) + pileCap.around_reinforcement_spacing * 0.5;

            TextPloter.AddTexWithArrow(db,ptDim.C3D(pileCap.length * 0.15, 0.75 * scale), ref ext, "横桥向", scale, 3, eDirection.E_RIGHT);

            TextPloter.AddTexWithArrow(db,M1.C3D(pileCap.length*0.5+12*scale, -pileCap.width*0.5 ), ref ext, "顺\\P桥\\P向", scale, 3, eDirection.E_TOP);

            DimPloter.AddLeft2RightBJ(db,"A", M1.C3D(-(pileCap.length * 0.5 + 16 * scale), -pileCap.width * 0.1), ref ext, scale, 3, true);
            DimPloter.AddLeft2RightBJ(db,"A", M1.C3D(pileCap.length * 0.5 + 10 * scale, -pileCap.width * 0.1), ref ext, scale, 3, false);
            DimPloter.AddTop2BottomBJ(db,"B", ptDim.C3D(-pileCap.length * 0.35, 5* scale), ref ext, scale);
            DimPloter.AddTop2BottomBJ(db,"B", M1.C3D(-0.35 * pileCap.length,-pileCap.width-9*scale), ref ext, scale,3,false);

            DimPloter.DimRot(db, ptTop.C3D(-pileCap.length * 0.5), ptLst[0], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, ptLst[0], ptLst[ptLst.Count-1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, topString, Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, ptTop.C3D(pileCap.length * 0.5), ptLst[ptLst.Count - 1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);

            DimPloter.DimRot(db, M1.C3D(0,-pileCap.width), ptLLst[0], ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, ptLLst[0], ptLLst[ptLLst.Count - 1], ptDimL.C3D(5 * scale), ref ext, 90, scale, leftString, Unit.Centimeter, Unit.Centimeter, 1);
            DimPloter.DimRot(db, M1.C3D(), ptLLst[ptLLst.Count - 1], ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 1);

            //DimPloter.DimRadius(db,M1.C3D(pileCap.length * 0.5, -pileCap.length * 0.25), M1.C3D(pileCap.length * 0.5, -pileCap.length * 0.25), 3 * scale, ref ext, scale, "净" + pileCap.concrete_protect_layer);
            #region 侧面钢筋编号
            //List<Point3d> list = new List<Point3d>();
            //// 右侧标记
            //int hIndex = 0;         // 标记外筋个数
            //if (ptRLst.Count <= 4)
            //{
            //    hIndex = 1;
            //}
            //else if (ptRLst.Count > 4 && ptRLst.Count <= 10)
            //{
            //    hIndex = 2;
            //}
            //else
            //{
            //    hIndex = 5;
            //}
            //if (ptRLst != null && ptRLst.Count > 0)
            //{
            //    for (int i = 0; i < hIndex && i < ptRLst.Count - 1; ++i)
            //    {
            //        Point3d flg1 = ptRLst[i];
            //        list.Add(flg1.C3D());
            //    }

            //    for (int i = ptRLst.Count - hIndex - 1; i < ptRLst.Count; ++i)
            //    {
            //        Point3d flg1 = ptRLst[i];
            //        list.Add(flg1.C3D());
            //    }

            //    SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_RIGHT, list, dicNo[5].ToString(), list.Count / 2, list.Count / 2, scale,false,5*scale);
            //}

            //// 底部标记
            //list.Clear();
            //int vIndex = 0;         // 标记外筋个数
            //if (ptBLst.Count <= 4)
            //{
            //    vIndex = 1;
            //}
            //else if (ptBLst.Count > 4 && ptBLst.Count <= 10)
            //{
            //    vIndex = 2;
            //}
            //else
            //{
            //    vIndex = 5;
            //}
            //if (ptBLst != null && ptBLst.Count > 0)
            //{
            //    for (int i = 0; i < vIndex && i < ptBLst.Count - 1; ++i)
            //    {
            //        Point3d flg1 = ptBLst[i];
            //        list.Add(flg1.C3D());
            //    }

            //    for (int i = ptBLst.Count - vIndex - 1; i < ptBLst.Count; ++i)
            //    {
            //        Point3d flg1 = ptBLst[i];
            //        list.Add(flg1.C3D());
            //    }

            //    SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_TOP, list, dicNo[5].ToString(), list.Count / 2, list.Count / 2, scale, false, 5 * scale);
            //}
            #endregion


            RebarPLPloter.CreateLineArrowDBNew(db, ref ext, ptRLst[ptRLst.Count-1].C3D(-dLen1,0), ArrowDirection.North, rSpaceLst, new List<double>(), dicNo[1].ToString(), scale, true, 5, 0 * scale);
            RebarPLPloter.CreateLineArrowDBNew(db, ref ext, ptLst[0].C3D(0,-dLen-4), ArrowDirection.West,  new List<double>(), tSpaceLst, dicNo[2].ToString(), scale, true, 5, 0 * scale);
            #endregion

            N5 = ptLst.Count*2+ (ptLLst.Count-2)*2;

        }

        #region 修改前备份(废)
        //public void PlotElevationPlan(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        //{
        //    //radius = radius * scale;
        //    Point2d CT = insertPoint;
        //    Point2d M1 = CT.C2D(0, -18 * scale);

        //    ext = new Extents2d(insertPoint, insertPoint);
        //    TextPloter.AddTitle(db,insertPoint, ref ext, "平面", "", scale);
        //    Point3d ptDim = M1.C3D(0, 10 * scale);
        //    Point3d ptDimL = M1.C3D(-0.5 * pileCap.length - 10 * scale);
        //    #region  绘制外轮廓
        //    PLPloter.AddPloy4(M1, 0.5 * pileCap.length, 0.5 * pileCap.length, pileCap.width, ref ext, "HM细线");

        //    //for (int i = 0; i < pileLocation.Length; i++)
        //    //{
        //    //    double pSizeLen = double.Parse(pileSize[i].ToString());
        //    //    double pLen = double.Parse(pileLocation[i].ToString());

        //    //    PLPloter.AddCircle(M1.C2D(-0.5 * length + pLen, -width * 0.5), pSizeLen * 0.5, ref ext, "H虚线", scale);
        //    //}
        //    #region 桩基外轮廓绘制

        //    double pileDia = pileCap.pile_diameter;
        //    string[] span = pileCap.pile_SpanL.Split('+');
        //    List<double> spanLst = new List<double>();
        //    double total = 0;
        //    for (int i = 0; i < span.Length; i++)
        //    {
        //        if (span[i].Contains("*"))
        //        {
        //            string[] sp = span[i].Split('*');
        //            int m = int.Parse(sp[0]);
        //            double v = double.Parse(sp[1]);
        //            for (int n = 0; n < m; n++)
        //            {
        //                spanLst.Add(v);
        //                total += v;
        //            }
        //        }
        //        else
        //        {
        //            if (double.Parse(span[i]) > 0)
        //            {
        //                spanLst.Add(double.Parse(span[i]));
        //                total += double.Parse(span[i]);
        //            }
        //            else
        //            {
        //                spanLst.Add(0);
        //            }
        //        }
        //    }
        //    string[] spanW = pileCap.pile_SpanW.Split('+');
        //    List<double> spanWLst = new List<double>();
        //    double totalW = 0;
        //    for (int i = 0; i < spanW.Length; i++)
        //    {
        //        if (spanW[i].Contains("*"))
        //        {
        //            string[] sp = spanW[i].Split('*');
        //            int m = int.Parse(sp[0]);
        //            double v = double.Parse(sp[1]);
        //            for (int n = 0; n < m; n++)
        //            {
        //                spanWLst.Add(v);
        //                totalW += v;
        //            }
        //        }
        //        else
        //        {
        //            if (double.Parse(spanW[i]) > 0)
        //            {
        //                spanWLst.Add(double.Parse(spanW[i]));
        //                totalW += double.Parse(spanW[i]);
        //            }
        //            else
        //            {
        //                spanWLst.Add(0);
        //            }
        //        }
        //    }
        //    if (spanLst.Count > 0)
        //    {
        //        Point2d ptCir;
        //        double len = 0;
        //        double wlen = 0;
        //        for (int i = 0; i < spanLst.Count; i++)
        //        {
        //            len += spanLst[i];

        //            if (i == 0)
        //            {
        //                for (int j = 0; j < spanWLst.Count; j++)
        //                {
        //                    wlen += spanWLst[j];
        //                    if (j == 0)
        //                    {
        //                        ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5, -totalW * 0.5);
        //                        PLPloter.AddCircle(ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
        //                    }
        //                    if (spanWLst[j] > 0)
        //                    {
        //                        ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5, -totalW * 0.5 + wlen);
        //                        PLPloter.AddCircle(ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
        //                    }
        //                }
        //            }
        //            if (spanLst[i] > 0)
        //            {
        //                wlen = 0;
        //                for (int j = 0; j < spanWLst.Count; j++)
        //                {
        //                    wlen += spanWLst[j];
        //                    if (j == 0)
        //                    {
        //                        ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5 + len, -totalW * 0.5);
        //                        PLPloter.AddCircle(ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
        //                    }
        //                    if (spanWLst[j] > 0)
        //                    {
        //                        ptCir = M1.C2D(0, -0.5 * pileCap.width).C2D(-total * 0.5 + len, -totalW * 0.5 + wlen);
        //                        PLPloter.AddCircle(ptCir, pileDia * 0.5, ref ext, "H虚线", scale);
        //                    }
        //                }

        //            }

        //        }

        //    }

        //    #endregion


        //    //轮廓标注
        //    DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.length), M1.C3D(0.5 * pileCap.length), ptDim, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
        //    DimPloter.DimAli(db,M1.C3D(-0.5 * pileCap.length), M1.C3D(-0.5 * pileCap.length, -pileCap.width), ptDimL, ref ext, scale, "", Unit.Centimeter, Unit.Centimeter);
        //    #endregion

        //    #region  绘制钢筋



        //    double diaX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5), 2, MidpointRounding.AwayFromZero);
        //    double diaY = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5), 2, MidpointRounding.AwayFromZero);


        //    double LT = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5), 2);
        //    double LH = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1 * 0.5), 2); ;
        //    double N1 = LT - GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1;
        //    double N2 = LH - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1;
        //    Point2d ptTop = M1.C2D(0, -pileCap.concrete_protect_layer - diaY);
        //    PLPloter.AddPloy4(ptTop.C2D(0, -radius), 0.5 * (LT - radius * 2), 0.5 * (LT - radius * 2), LH - radius, ref ext, "H钢筋");
        //    List<Point3d> ptLst = new List<Point3d>();
        //    List<double> topSpaceLst = new List<double>();
        //    string topString = "";
        //    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptTop.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer, 0), radius, LT, LT, pileCap.around_reinforcement_spacing, diaX, 0, out ptLst, out topSpaceLst, out topString, eDirection.E_TOP);

        //    Point2d ptBotom = ptTop.C2D(0, -LH + diaY);
        //    List<Point3d> ptBLst = new List<Point3d>();
        //    List<double> btSpaceLst = new List<double>();
        //    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer, 0), radius, LT, LT, pileCap.around_reinforcement_spacing, diaX, radius, out ptBLst, out btSpaceLst, out topString, eDirection.E_BOTTOM);

        //    List<Point3d> ptLLst = new List<Point3d>();
        //    string leftString = "";
        //    List<double> leftSpaceLst = new List<double>();
        //    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(-pileCap.length * 0.5 + pileCap.concrete_protect_layer + diaX, -diaY), radius, LH, LH, pileCap.around_reinforcement_spacing, 0, 0, out ptLLst, out leftSpaceLst, out leftString, eDirection.E_LEFT);

        //    List<Point3d> ptRLst = new List<Point3d>();
        //    List<double> rightSpaceLst = new List<double>();
        //    SteelBarPileCap.CreateAvgCircleHatchList(db, ref ext, ptBotom.C2D(pileCap.length * 0.5 - pileCap.concrete_protect_layer - diaX, -diaY), radius, LH, LH, pileCap.around_reinforcement_spacing, 0, 0, out ptRLst, out rightSpaceLst, out leftString, eDirection.E_RIGHT);

        //    List<double> tSpaceLst = new List<double>();
        //    List<double> rSpaceLst = new List<double>();
        //    for (int i = 1; i < ptLst.Count - 1; i++)
        //    {
        //        PLPloter.AddLine(db,ptLst[i].C2D(0, -radius), ptBLst[i].C2D(0, radius), ref ext, "H钢筋");

        //        if (i == 1)
        //            tSpaceLst.Add(ptLst[i].C2D().X - ptLst[i - 1].C2D(radius).X);
        //        else if (i == ptLst.Count - 2)
        //        {
        //            tSpaceLst.Add(ptLst[i].C2D().X - ptLst[i - 1].C2D().X);
        //            tSpaceLst.Add(ptLst[i + 1].C2D(0, -radius).X - ptLst[i].C2D().X);
        //        }
        //        else
        //            tSpaceLst.Add(ptLst[i].C2D().X - ptLst[i - 1].C2D().X);
        //    }
        //    for (int i = 1; i < ptLLst.Count - 1; i++)
        //    {
        //        PLPloter.AddLine(db,ptLLst[i].C2D(radius), ptRLst[i].C2D(-radius), ref ext, "H钢筋");
        //        if (i == 1)
        //            rSpaceLst.Add(ptLLst[i].C2D().Y - ptLLst[i - 1].C2D(0, radius).Y);
        //        else if (i == ptLLst.Count - 2)
        //        {
        //            rSpaceLst.Add(ptLLst[i].C2D().Y - ptLLst[i - 1].C2D().Y);
        //            rSpaceLst.Add(ptLLst[i + 1].C2D(0, -radius).Y - ptLLst[i].C2D().Y);
        //        }
        //        else
        //            rSpaceLst.Add(ptLLst[i].C2D().Y - ptLLst[i - 1].C2D().Y);

        //    }

        //    double LTT = pileCap.length - 2 * (pileCap.concrete_protect_layer + (int)pileCap.around_h_reinforcement_diameter * 0.1 * 0.5) - pileCap.erection_reinforcement_l_spacing * 0.5;
        //    int numErection = (int)((LH - pileCap.erection_reinforcement_w_spacing) / pileCap.erection_reinforcement_w_spacing) + 1;
        //    for (int i = 1; i <= numErection; i++)
        //    {
        //        string eString = "";
        //        List<Point3d> ptALst = new List<Point3d>();
        //        int numW = (int)(pileCap.erection_reinforcement_w_spacing / pileCap.around_h_reinforcement_spacing);
        //        int numL = (int)(pileCap.erection_reinforcement_l_spacing / pileCap.around_h_reinforcement_spacing);
        //        SteelBarPileCap.CreateCircleHatchList(db, ref ext, new Point2d(ptLst[numL].X, ptLLst[numW].Y).C2D(radius, pileCap.erection_reinforcement_w_spacing * (i - 1) - radius), radius, LTT, LTT, pileCap.erection_reinforcement_l_spacing, 0, 0, out ptALst, eDirection.E_TOP);
        //    }


        //    #endregion

        //    #region  标注 及编号

        //    int num = (int)(LT / pileCap.around_reinforcement_spacing);
        //    double avg = Math.Round((LT - pileCap.around_reinforcement_spacing * (num - 1)) * 0.5, 1);
        //    double dLen = avg + pileCap.around_reinforcement_spacing * ((int)(num - num * 0.75)) + pileCap.around_reinforcement_spacing * 0.5;

        //    int num1 = (int)(LH / pileCap.around_reinforcement_spacing);
        //    double avg1 = Math.Round((LH - pileCap.around_reinforcement_spacing * (num1 - 1)) * 0.5, 1);
        //    double dLen1 = avg + pileCap.around_reinforcement_spacing * ((int)(num - num * 0.25)) + pileCap.around_reinforcement_spacing * 0.5;

        //    TextPloter.AddTexWithArrow(db,ptDim.C3D(pileCap.length * 0.15, 0.75 * scale), ref ext, "横桥向", scale, 3, eDirection.E_RIGHT);

        //    TextPloter.AddTexWithArrow(db,M1.C3D(pileCap.length * 0.5 + 15 * scale, -pileCap.width * 0.5), ref ext, "顺\\P桥\\P向", scale, 3, eDirection.E_TOP);

        //    DimPloter.AddLeft2RightBJ(db,"A", M1.C3D(-(pileCap.length * 0.5 + 16 * scale), -pileCap.width * 0.1), ref ext, scale, 3, true);
        //    DimPloter.AddLeft2RightBJ(db,"A", M1.C3D(pileCap.length * 0.5 + 10 * scale, -pileCap.width * 0.1), ref ext, scale, 3, false);
        //    DimPloter.AddTop2BottomBJ(db,"B", ptDim.C3D(-pileCap.length * 0.35, 5 * scale), ref ext, scale);
        //    DimPloter.AddTop2BottomBJ(db,"B", M1.C3D(-0.35 * pileCap.length, -pileCap.width - 9 * scale), ref ext, scale, 3, false);

        //    DimPloter.DimRot(db, ptTop.C3D(-pileCap.length * 0.5), ptLst[0], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
        //    DimPloter.DimRot(db, ptLst[0], ptLst[ptLst.Count - 1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, topString, Unit.Centimeter, Unit.Centimeter, 1);
        //    DimPloter.DimRot(db, ptTop.C3D(pileCap.length * 0.5), ptLst[ptLst.Count - 1], ptDim.C3D(0, -5 * scale), ref ext, 0, scale, "", Unit.Centimeter, Unit.Centimeter, 1);

        //    DimPloter.DimRot(db, M1.C3D(0, -pileCap.width), ptLLst[0], ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 1);
        //    DimPloter.DimRot(db, ptLLst[0], ptLLst[ptLLst.Count - 1], ptDimL.C3D(5 * scale), ref ext, 90, scale, leftString, Unit.Centimeter, Unit.Centimeter, 1);
        //    DimPloter.DimRot(db, M1.C3D(), ptLLst[ptLLst.Count - 1], ptDimL.C3D(5 * scale), ref ext, 90, scale, "", Unit.Centimeter, Unit.Centimeter, 1);

        //    //DimPloter.DimRadius(db,M1.C3D(pileCap.length * 0.5, -pileCap.length * 0.25), M1.C3D(pileCap.length * 0.5, -pileCap.length * 0.25), 3 * scale, ref ext, scale, "净" + pileCap.concrete_protect_layer);
        //    #region 侧面钢筋编号
        //    List<Point3d> list = new List<Point3d>();
        //    // 右侧标记
        //    int hIndex = 0;         // 标记外筋个数
        //    if (ptRLst.Count <= 4)
        //    {
        //        hIndex = 1;
        //    }
        //    else if (ptRLst.Count > 4 && ptRLst.Count <= 10)
        //    {
        //        hIndex = 2;
        //    }
        //    else
        //    {
        //        hIndex = 5;
        //    }
        //    if (ptRLst != null && ptRLst.Count > 0)
        //    {
        //        for (int i = 0; i < hIndex && i < ptRLst.Count - 1; ++i)
        //        {
        //            Point3d flg1 = ptRLst[i];
        //            list.Add(flg1.C3D());
        //        }

        //        for (int i = ptRLst.Count - hIndex - 1; i < ptRLst.Count; ++i)
        //        {
        //            Point3d flg1 = ptRLst[i];
        //            list.Add(flg1.C3D());
        //        }

        //        SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_RIGHT, list, dicNo[5].ToString(), list.Count / 2, list.Count / 2, scale, false, 5 * scale);
        //    }

        //    // 底部标记
        //    list.Clear();
        //    int vIndex = 0;         // 标记外筋个数
        //    if (ptBLst.Count <= 4)
        //    {
        //        vIndex = 1;
        //    }
        //    else if (ptBLst.Count > 4 && ptBLst.Count <= 10)
        //    {
        //        vIndex = 2;
        //    }
        //    else
        //    {
        //        vIndex = 5;
        //    }
        //    if (ptBLst != null && ptBLst.Count > 0)
        //    {
        //        for (int i = 0; i < vIndex && i < ptBLst.Count - 1; ++i)
        //        {
        //            Point3d flg1 = ptBLst[i];
        //            list.Add(flg1.C3D());
        //        }

        //        for (int i = ptBLst.Count - vIndex - 1; i < ptBLst.Count; ++i)
        //        {
        //            Point3d flg1 = ptBLst[i];
        //            list.Add(flg1.C3D());
        //        }

        //        SteelBarPileCap.CreateRebarPointLine(db, ref ext, eDirection.E_TOP, list, dicNo[5].ToString(), list.Count / 2, list.Count / 2, scale, false, 5 * scale);
        //    }
        //    #endregion


        //    RebarPLPloter.CreateLineArrowDBNew(db, ref ext, ptRLst[ptRLst.Count - 1].C3D(-dLen1, -radius), ArrowDirection.North, rSpaceLst, new List<double>(), dicNo[2].ToString(), scale, true, scale, 0 * scale);
        //    RebarPLPloter.CreateLineArrowDBNew(db, ref ext, ptLst[0].C3D(radius, -dLen - 4), ArrowDirection.West, new List<double>(), tSpaceLst, dicNo[1].ToString(), scale, true, scale, 0 * scale);
        //    #endregion

        //    N5 = ptLst.Count * 2 + (ptLLst.Count - 2) * 2;

        //}
        #endregion


        /// <summary>
        /// 编号处理算法
        /// </summary>
        private void InitPileNo()
        {
            //1-12号钢筋的编号
            int No = 2;
            dicNo = new Dictionary<int, int>();
            for (int i = 1; i < 11; i++)
            {
                dicNo.Add(i, i);
            }
            if (pileCap.top_l_reinforcement_diameter == pileCap.bottom_l_reinforcement_diameter)
            {
                dicNo[3] = dicNo[1];
            }
            else
            {
                No++;
                dicNo[3] = No;
            }
            if (pileCap.top_w_reinforcement_diameter == pileCap.bottom_w_reinforcement_diameter)
            {
                dicNo[4] = dicNo[2];
            }
            else
            {
                No++;
                dicNo[4] = No;
            }
            No++;
            dicNo[5] = No;
            No++;
            dicNo[6] = No;
            No++;
            dicNo[7] = No;
            if (pileCap.erection_reinforcement_diameter != eDB.None)
            {

                No++;
                dicNo[8] = No;
            }
            No++;
            dicNo[9] = No;

            No++;
            dicNo[10] = No;
            #region 逻辑有问题（参考后台的,应该是存在就添加）
            //if (pileCap.reinforcement_net_l_diameter != eDB.None)
            //{
            //    No++;
            //    dicNo[9] = No;

            //}
            //if (pileCap.reinforcement_net_w_diameter != eDB.None)
            //{
            //    if (pileCap.length != pileCap.width)
            //    {
            //        No++;
            //        dicNo[10] = No;
            //    } 
            //    else
            //    {
            //        dicNo[10] = No;
            //    }             
            //}

            No++;
            dicNo[11] = No;

            No++;
            dicNo[12] = No;

            No++;
            dicNo[13] = No;
            #endregion
        }

        public void RendeDetail(ref Database db, out Extents2d ext, Point2d insertPoint, int scale = 1)
        {
            CalculateRebar();
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -2 * scale);
            ext = new Extents2d(insertPoint, insertPoint);
            
            List<string> list = new List<string>();
            list.Add("编号");
            list.Add("直径\\P(mm)");
            list.Add("大样");
            list.Add("单根长\\P(cm)");
            list.Add("根数");
            list.Add("总长\\P(m)");
            list.Add("单位重\\P(kg/m)");
            list.Add("总重\\P(kg)");
            //list.Add("小计(kg)");
            double height = 0;
            double width = 0;
            PierModelTablePloter.DrawCapRebarTable(db, ref ext, M1.C3D(-0.5 * pileCap.width + pileCap.concrete_protect_layer), rebarLst, list, rebarLst.Count + 1, list.Count, ref height, ref width, Extensions.curFont, scale,pileCap.reinforcement_grade, true);
            double ActualWidth = 0, ActualHeight = 0;
            MText txt = TextPloter.GetTextActualWidth(db, "承台钢筋明细表", scale, out ActualWidth, out ActualHeight, 4);
            TextPloter.AddMText(db,M1.C3D(-0.5 * pileCap.width + pileCap.concrete_protect_layer+ (width - ActualWidth) / 2, ActualHeight + scale * 2), ref ext, "承台钢筋明细表", scale, 4, ActualWidth + 2*scale, Extensions.curFont);

            List<string> list1 = new List<string>();
            list1.Add("名称及规格");
            list1.Add("名称及规格");
            list1.Add("单位");
            list1.Add("总重");
            list1.Add("合计");
            double height1 = 0;
            double width1 = 0;
            double volumn = pileCap.width*0.01 * pileCap.length * 0.01 * pileCap.height * 0.01;
            double volumnLayer = (pileCap.width + pileCap.cushion_cornice_length) * 0.01 * (pileCap.length+pileCap.cushion_cornice_length) * 0.01 * pileCap.cushion_thickness * 0.01;
            txt = TextPloter.GetTextActualWidth(db, "承台材料数量表(全桥" + pileCap.structure_number + "个)", scale, out ActualWidth, out ActualHeight, 4);
            List<Tuple<eDB, double, double, string>> tuNet = new List<Tuple<eDB, double, double, string>>();
            double LNET = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[pileCap.reinforcement_net_l_diameter] * 0.1, 1);
            double WNET = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[pileCap.reinforcement_net_w_diameter] * 0.1, 1);

            double LFNET = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[fsDB] * 0.1, 1);
            double WFNET = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[fsDB] * 0.1, 1);
            double HFNET = Math.Round(pileCap.height - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[fsDB] * 0.1, 1);
            Tuple<eDB, double, double, string> tu = new Tuple<eDB, double, double, string>(pileCap.reinforcement_net_l_diameter, Math.Round(LNET*0.01 * WNET*0.01,3),15, strfsDiameter);
            tuNet.Add(tu);
            double area = Math.Round(LFNET * 0.01 * WFNET * 0.01, 3)+2* Math.Round(LFNET * 0.01 * HFNET * 0.01, 3) + 2 * Math.Round(WFNET * 0.01 * HFNET * 0.01, 3);
            tu = new Tuple<eDB, double, double, string>(fsDB, area,10,strfsDiameter);
            tuNet.Add(tu);

            PierModelTablePloter.DrawCapMaterialsTable(db, ref ext, M1.C3D(-0.5 * pileCap.width + pileCap.concrete_protect_layer, -height - ActualHeight * 3), rebarLst, list1, pileCap.structure_number, volumn, volumnLayer, list1.Count, ref height1, ref width1, Extensions.curFont, tuNet, scale, pileCap.reinforcement_grade, pileCap.main_reinforcement_grade, pileCap.bottom_l_reinforcement_diameter.ToString()+","+ pileCap.bottom_w_reinforcement_diameter.ToString(),pileCap.concrete_no);
            TextPloter.AddMText(db,M1.C3D(-0.5 * pileCap.width + pileCap.concrete_protect_layer + (width1 - ActualWidth) / 2, -height - ActualHeight * 2 + scale * 2), ref ext, "承台材料数量表(全桥" + pileCap.structure_number + "个)", scale, 4, ActualWidth + 2 * scale, Extensions.curFont);

            // 文字
            string text = "注";
            Point3d p1 = M1.C3D(-0.5 * pileCap.width + pileCap.concrete_protect_layer + width1 + scale * 3, -height - ActualHeight * 3);
            TextPloter.AddMText(db,p1, ref ext, text, scale, 3, 50, Extensions.curFont);

            text = @"1.本图尺寸除钢筋直径以毫米计外，余均以厘米为单位。
2.承台钢筋如与墩身钢筋冲突，可适当调整承台钢筋。
3.在距离承台底部5cm处设置一层" + strfsDiameter + "12钢筋网，间距15×15cm。\\P" +
"4.在承台侧面及顶面分别设置一层" + strfsDiameter + (int)fsDB + "防裂钢筋网，间距10×10cm。\\P" +
"5.N" + dicNo[8] + "钢筋按" + pileCap.erection_reinforcement_w_spacing + "×" + pileCap.erection_reinforcement_l_spacing + "cm间距双向阵列布置。";
            Point3d p2 = M1.C3D(-0.5 * pileCap.width + pileCap.concrete_protect_layer + width1 + scale * 5, -height - ActualHeight * 3 - 4.5 * scale);
            TextPloter.AddMText(db,p2, ref ext, text, scale, 3, 78 * scale, "SRB.tssdeng");
            text = @"\P6.承台垫层（图中未视）采用C15素混凝土，厚度" + pileCap.cushion_thickness + "cm，平面尺寸分别超出承台平面尺寸各" + pileCap.cushion_cornice_length + "cm。\\P"+
@"7.本图适用于" + pileCap.pier_name + "墩承台。";
            p2 = M1.C3D(-0.5 * pileCap.width + pileCap.concrete_protect_layer + width1 + scale * 5, -height - ActualHeight * 3 - 4.5 * scale-7*3*scale*1.5+3 * scale*0.5);
            TextPloter.AddMText(db,p2, ref ext, text, scale, 3, 78 * scale, "SRB.HT");
            //string txt1 = " 3.在距离承台底部5cm处设置一层C12钢筋网，间距15×15cm。";
            //TextPloter.AddDBText(db,p2.C3D(-2*scale, -3 * scale * 4), ref ext, txt1, scale, 3, Extensions.curFont, 0);
            //txt1 = "4.在承台侧面及顶面分别设置一层A8钢筋网，间距10×10cm。";

            try
            {
                BatchInsertQuentity(rebarLst,tuNet);
            }
            catch (Exception ex)
            {

            }
        }
        public void CalculateRebar()
        {
            double diaX = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double diaY = (double)Math.Round((decimal)(GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1 * 0.5), 1, MidpointRounding.AwayFromZero);
            double LN0 = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1*0.5), 1);
            double WN0 = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1*0.5), 1);
            double LN = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1), 1);
            double WN = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_h_reinforcement_diameter] * 0.1), 1);
            double LH = Math.Round(pileCap.height - pileCap.concrete_protect_layer - 10 - GeneralRebar.outerDiaNew[pileCap.bottom_l_reinforcement_diameter] * 0.1 * 0.5 - GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1 * 0.5 - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1, 1);
            double ALN = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_w_reinforcement_diameter] * 0.1*0.5), 1);
            double AWN = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer + GeneralRebar.outerDiaNew[pileCap.around_l_reinforcement_diameter] * 0.1*0.5), 1);
            double LNET = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[pileCap.reinforcement_net_l_diameter] * 0.1, 1);
            double WNET = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[pileCap.reinforcement_net_w_diameter] * 0.1, 1);

            double LFNET = Math.Round(pileCap.length - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[fsDB] * 0.1, 1);
            double WFNET = Math.Round(pileCap.width - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[fsDB] * 0.1, 1);
            double HFNET = Math.Round(pileCap.height - 2 * (pileCap.concrete_protect_layer) - GeneralRebar.outerDiaNew[fsDB] * 0.1, 1);

            Tuple<int, eSampleType, eDB, int, double,string> tu;
            //double len = LN;
            if (pileCap.top_l_reinforcement_diameter == pileCap.bottom_l_reinforcement_diameter)
            {
                tu = new Tuple<int, eSampleType, eDB, int, double, string>(1, eSampleType.UT, pileCap.bottom_l_reinforcement_diameter, N1 * pileCap.bottom_reinforcement_layers_number+N3 * pileCap.top_reinforcement_layers_number, LN- GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1  + GeneralRebar.outerDiaHoke[pileCap.top_l_reinforcement_diameter]*2,strMainDiameter);
                rebarLst.Add(tu);
            }
            else
            {
                tu = new Tuple<int, eSampleType, eDB, int, double, string>(1, eSampleType.UT, pileCap.bottom_l_reinforcement_diameter, N1 * pileCap.bottom_reinforcement_layers_number, LN - GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaHoke[pileCap.bottom_l_reinforcement_diameter] * 2, strMainDiameter);
                rebarLst.Add(tu);
                tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[3], eSampleType.UT, pileCap.top_l_reinforcement_diameter, N3 * pileCap.top_reinforcement_layers_number, LN - GeneralRebar.outerDiaNew[pileCap.top_l_reinforcement_diameter] * 0.1, strMainDiameter);
                rebarLst.Add(tu);
            }

            if (pileCap.top_w_reinforcement_diameter == pileCap.bottom_w_reinforcement_diameter)
            {
                tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[2], eSampleType.UT, pileCap.bottom_w_reinforcement_diameter, N2 * pileCap.bottom_reinforcement_layers_number+ N4 * pileCap.top_reinforcement_layers_number, WN - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaHoke[pileCap.top_w_reinforcement_diameter] * 2, strMainDiameter);
                rebarLst.Add(tu);
            }
            else
            {
                tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[2], eSampleType.UT, pileCap.bottom_w_reinforcement_diameter, N2 * pileCap.bottom_reinforcement_layers_number, WN - GeneralRebar.outerDiaNew[pileCap.bottom_w_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaHoke[pileCap.bottom_w_reinforcement_diameter] * 2, strMainDiameter);
                rebarLst.Add(tu);
                tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[4], eSampleType.UT, pileCap.top_w_reinforcement_diameter, N4 * pileCap.top_reinforcement_layers_number, WN - GeneralRebar.outerDiaNew[pileCap.top_w_reinforcement_diameter] * 0.1 + GeneralRebar.outerDiaHoke[pileCap.top_w_reinforcement_diameter] * 2, strMainDiameter);
                rebarLst.Add(tu);
            }


            tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[5], eSampleType.UT, pileCap.around_h_reinforcement_diameter, N5, LH + GeneralRebar.outerDiaHoke[pileCap.around_h_reinforcement_diameter] * 2, strDiameter);
            rebarLst.Add(tu);

            tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[6], eSampleType.UT, pileCap.around_l_reinforcement_diameter, N6, ALN + GeneralRebar.outerDiaHoke[pileCap.around_l_reinforcement_diameter] * 2, strDiameter);
            rebarLst.Add(tu);

            tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[7], eSampleType.UT, pileCap.around_w_reinforcement_diameter, N7, AWN + GeneralRebar.outerDiaHoke[pileCap.around_w_reinforcement_diameter] * 2, strDiameter);
            rebarLst.Add(tu);

            tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[8], eSampleType.UT, pileCap.erection_reinforcement_diameter, N8L * N8W, LH + GeneralRebar.outerDiaHoke[pileCap.erection_reinforcement_diameter] * 2, strDiameter);
            rebarLst.Add(tu);
            int numH = 0;
            double HL = LH - pileCap.bottom_reinforcement_layers_spacing * pileCap.bottom_reinforcement_layers_number - pileCap.top_reinforcement_layers_spacing * pileCap.top_reinforcement_layers_number;

            if (pileCap.height > 300)
            {
                numH = (int)(HL / pileCap.erection_reinforcement_h_spacing);
                int  numS =(int) (pileCap.erection_reinforcement_w_spacing / pileCap.around_h_reinforcement_spacing);
                tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[9], eSampleType.UT, pileCap.around_l_reinforcement_diameter, numH* (int)(N1 / numS), LN0 + GeneralRebar.outerDiaHoke[pileCap.around_l_reinforcement_diameter] * 2, strDiameter);
                rebarLst.Add(tu);


                tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[10], eSampleType.UT, pileCap.around_l_reinforcement_diameter, numH * (int)(N2 / numS), WN0 + GeneralRebar.outerDiaHoke[pileCap.around_l_reinforcement_diameter] * 2, strDiameter);
                rebarLst.Add(tu);
            }
                rebarLst.Sort();
            #region 钢筋网
            //if (pileCap.reinforcement_net_w_diameter != eDB.None&& pileCap.reinforcement_net_l_diameter != eDB.None)
            //{
            //    if (pileCap.reinforcement_net_w_diameter == pileCap.reinforcement_net_l_diameter)
            //    {
            //        if (pileCap.length != pileCap.width)
            //        {
            //            tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[9], eSampleType.UN, pileCap.reinforcement_net_w_diameter, N9, LNET, "C");
            //            rebarLst.Add(tu);

            //            tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[10], eSampleType.UN, pileCap.reinforcement_net_l_diameter, N10, WNET, "C");
            //            rebarLst.Add(tu);
            //        }
            //        else
            //        {
            //            tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[9], eSampleType.UN, pileCap.reinforcement_net_w_diameter, N9+N10, LNET, "C");
            //            rebarLst.Add(tu);
            //        }
            //    }
            //    else
            //    {
            //        tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[9], eSampleType.UN, pileCap.reinforcement_net_w_diameter, N9, LNET, "C");
            //        rebarLst.Add(tu);

            //        tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[10], eSampleType.UN, pileCap.reinforcement_net_l_diameter, N10, WNET, "C");
            //        rebarLst.Add(tu);
            //    }
            //}

            //int N11 = ((int)(HFNET / 10) + 1) * 2 + (int)(LFNET / 10) + 1;
            //tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[11], eSampleType.UN, fsDB, N10, WFNET, "C");
            //rebarLst.Add(tu);

            //int N12 = ((int)(HFNET / 10) + 1) * 2 + (int)(WFNET / 10) + 1;
            //tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[12], eSampleType.UN, fsDB, N12, LFNET, "C");
            //rebarLst.Add(tu);

            //int N13 = ((int)(LFNET / 10) + (int)(WFNET / 10) + 2) * 2; 
            //tu = new Tuple<int, eSampleType, eDB, int, double, string>(dicNo[13], eSampleType.UN, fsDB, N13, HFNET, "C");
            //rebarLst.Add(tu);
            #endregion


        }

        private void BatchInsertQuentity(List<Tuple<int, eSampleType, eDB, int, double, string>> rebarLst,List<Tuple<eDB, double, double, string>> tuNet)
        {
            List<string> sqlList = new List<string>();
            if (rebarLst.Count > 0)
            {
                eDB mainDia = pileCap.bottom_l_reinforcement_diameter;
                eDB mainWDia = pileCap.bottom_w_reinforcement_diameter;
                string main_reinforcement_grade = pileCap.main_reinforcement_grade;
                string reinforcement_grade = pileCap.reinforcement_grade;
                string delSql = "delete from busi_engineering_quantity where  bridge_id='" + bridgeId + "' and (portable_belong_part=3 or belong_part=3) ";
                #region 数据合并
                // 数据合并
                Dictionary<string, List<int>> dic = new Dictionary<string, List<int>>();
                for (int i = 0; i < rebarLst.Count; ++i)
                {
                    string strNo = rebarLst[i].Item3.ToString();
                    if (dic.Count == 0)
                    {
                        List<int> list = new List<int>();
                        list.Add(i);
                        dic.Add(strNo, list);
                    }
                    else
                    {
                        if (!dic.ContainsKey(strNo))
                        {
                            List<int> list = new List<int>();
                            list.Add(i);
                            dic.Add(strNo, list);
                        }
                        else
                        {
                            List<int> list = new List<int>();
                            dic.TryGetValue(strNo, out list);
                            list.Add(i);
                            dic[strNo] = list;
                        }
                    }
                }
                //dic = dic.OrderByDescending(f => f.Key).ToDictionary(f => f.Key, f => f.Value);
                #endregion
                dic = dic.OrderByDescending(f => f.Key).ToDictionary(f => f.Key, f => f.Value);
                string remark = "承台钢筋";
                string material = "钢筋";
                string materialCode = main_reinforcement_grade;
                string materielSpecs = mainDia.ToString();


                double allWeight = 0;
                int count = pileCap.structure_number;
                int totalCap = 0;
                int totalWCap = 0;
                //int netCount = tuNet.Count;
                foreach (KeyValuePair<string, List<int>> pr in dic)
                {
                    string strNo = "钢筋";
                    string unit = "kg";
                    eDB diameter = eDB.None;
                    double totallength = 0;
                    // 设置表数据
                    for (int i = 0; i < pr.Value.Count; ++i)
                    {
                        // 钢筋编号
                        diameter = rebarLst[pr.Value[i]].Item3;                         // 直径
                        totallength += rebarLst[pr.Value[i]].Item4 * rebarLst[pr.Value[i]].Item5;
                        if (diameter == mainDia)
                        {
                            if(rebarLst[pr.Value[i]].Item5*0.01>12)
                            {
                                totalCap += ((int)(rebarLst[pr.Value[i]].Item5 * 0.01 / 12)) * rebarLst[pr.Value[i]].Item4;
                            }
                        }
                        else if ( diameter == mainWDia)
                        {
                            if (rebarLst[pr.Value[i]].Item5 * 0.01 > 12)
                            {
                                totalWCap += ((int)(rebarLst[pr.Value[i]].Item5 * 0.01 / 12)) * rebarLst[pr.Value[i]].Item4;
                            }
                        }
                    }
                    double weight = GlobalFuncs.GetUnitWeight(diameter);
                    double totalWeight = totallength * 0.01 * weight;

                    allWeight += totalWeight * count;
                    string strDiameter = "Ф" + (int)diameter;

                    remark = "承台钢筋";
                    material = "钢筋";
                    materialCode = main_reinforcement_grade;
                    materielSpecs = diameter.ToString();
                    if (diameter == mainDia || diameter == mainWDia)
                    {
                        materialCode = main_reinforcement_grade;
                       
                    }
                    else
                        materialCode = reinforcement_grade;
                    string id = Guid.NewGuid().ToString();
                    string sql = "insert into busi_engineering_quantity(id,bridge_id,materiel,materiel_code,materiel_specs,unit,"
                        + "unit_weight,total_weight,is_auto,belong_part,portable_belong_part,remark)"
                        + "values('" + id + "','" + bridgeId + "','" + material + "','" + materialCode + "','" + materielSpecs + "','kg','"
                        + weight + "','" + allWeight + "','2','3','3','" + remark + "')";
                    sqlList.Add(sql);
                }

                double allWeightNet = 0;
                int netCount = tuNet.Count;
                foreach (Tuple<eDB, double, double, string> item in tuNet)
                {
                    string strNo = "焊接钢筋网";
                    string unit = "kg";
                    eDB diameter = eDB.None;

                    double weight = GlobalFuncs.GetUnitAreaWeight(item.Item1, item.Item3) * 1.1;
                    double totalWeight = item.Item2 * weight;
                    allWeightNet += totalWeight * count;

                    remark = "承台焊接钢筋网";
                    material = "焊接钢筋网";
                    materialCode = main_reinforcement_grade;
                    materielSpecs = "Ф" + ((int)diameter).ToString() + "焊接钢筋网";
                    string id = Guid.NewGuid().ToString();
                    string sql = "insert into busi_engineering_quantity(id,bridge_id,materiel,materiel_code,materiel_specs,unit,"
                        + "unit_weight,total_weight,is_auto,belong_part,portable_belong_part,remark)"
                        + "values('" + id + "','" + bridgeId + "','" + material + "','" + materialCode + "','" + materielSpecs + "','kg','"
                        + weight + "','" + allWeightNet + "','2','3','3','" + remark + "')";
                    sqlList.Add(sql);

                }
                double volumn = pileCap.width * 0.01 * pileCap.length * 0.01 * pileCap.height * 0.01;
                material = "混凝土";
                materialCode = material;
                materielSpecs =pileCap.concrete_no;
                remark = "承台混凝土";
                string id1 = Guid.NewGuid().ToString();
                string sqlIn = "insert into busi_engineering_quantity(id,bridge_id,materiel,materiel_code,materiel_specs,unit,"
                    + "total_weight,is_auto,belong_part,portable_belong_part,remark)"
                    + "values('" + id1 + "','" + bridgeId + "','" + material + "','" + materialCode + "','" + materielSpecs + "','m3','"
                    + volumn*count + "','2','3','3','" + remark + "')";
                sqlList.Add(sqlIn);
                double volumnLayer = (pileCap.width + pileCap.cushion_cornice_length) * 0.01 * (pileCap.length + pileCap.cushion_cornice_length) * 0.01 * pileCap.cushion_thickness * 0.01;
                material = "混凝土";
                materialCode = material;
                materielSpecs = "C15";
                remark = "垫层混凝土";
                id1 = Guid.NewGuid().ToString();
                sqlIn = "insert into busi_engineering_quantity(id,bridge_id,materiel,materiel_code,materiel_specs,unit,"
                    + "total_weight,is_auto,belong_part,portable_belong_part,remark)"
                    + "values('" + id1 + "','" + bridgeId + "','" + material + "','" + materialCode + "','" + materielSpecs + "','m3','"
                    + volumn * count + "','2','3','3','" + remark + "')";
                sqlList.Add(sqlIn);


                if(totalCap>0)
                {
                    material = "钢筋连接器";
                    materialCode = material;
                    materielSpecs = mainDia.ToString();
                    remark = "承台钢筋连接器";
                    id1 = Guid.NewGuid().ToString();
                    sqlIn = "insert into busi_engineering_quantity(id,bridge_id,materiel,materiel_code,materiel_specs,unit,"
                        + "total_weight,is_auto,belong_part,portable_belong_part,remark)"
                        + "values('" + id1 + "','" + bridgeId + "','" + material + "','" + materialCode + "','" + materielSpecs + "','个','"
                        + totalCap*count + "','2','3','3','" + remark + "')";
                    sqlList.Add(sqlIn);
                }
                if (totalWCap > 0)
                {
                    material = "钢筋连接器";
                    materialCode = material;
                    materielSpecs = mainDia.ToString();
                    remark = "承台钢筋连接器";
                    id1 = Guid.NewGuid().ToString();
                    sqlIn = "insert into busi_engineering_quantity(id,bridge_id,materiel,materiel_code,materiel_specs,unit,"
                        + "total_weight,is_auto,belong_part,portable_belong_part,remark)"
                        + "values('" + id1 + "','" + bridgeId + "','" + material + "','" + materialCode + "','" + materielSpecs + "','个','"
                        + totalWCap * count + "','2','3','3','" + remark + "')";
                    sqlList.Add(sqlIn);
                }
            }
           
        }


    }

}
